<template>
  <view class="container">
    <view class="status-bar"></view>
    
    <view class="header">
      <view class="header-left">
        <view class="back-btn" @tap="goBack">
          <text class="icon">←</text>
        </view>
      </view>
      <view class="header-center">
        <text class="title">研学课程</text>
        <text class="subtitle">STUDY COURSES</text>
      </view>
      <view class="header-right">
        <view class="help-btn">
          <text class="icon">?</text>
        </view>
      </view>
    </view>

    <scroll-view class="main-content" scroll-y>
      <view class="course-list">
        <view class="course-item" v-for="course in courses" :key="course.id" @tap="selectCourse(course)">
          <view class="course-image">
            <text class="image-placeholder">{{ course.title }}视频封面</text>
          </view>
          <view class="course-info">
            <text class="course-title">{{ course.title }}</text>
            <text class="course-desc">{{ course.description }}</text>
            <view class="course-meta">
              <text class="course-duration">{{ course.duration }}</text>
              <view class="free-tag">
                <text>免费</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

const courses = ref([
  {
    id: 1,
    title: '朱熹文化探索',
    category: '历史文化',
    description: '深入了解朱熹思想与武夷山摩崖石刻的历史渊源',
    duration: '2小时',
    ageGroup: '8-16岁',
    price: 120
  },
  {
    id: 2,
    title: '石刻拓印体验',
    category: '手工体验',
    description: '亲手制作摩崖石刻拓片，感受传统技艺魅力',
    duration: '1.5小时',
    ageGroup: '6-18岁',
    price: 80
  },
  {
    id: 3,
    title: '武夷山地质科普',
    category: '自然科学',
    description: '探索武夷山独特的丹霞地貌与石刻形成过程',
    duration: '3小时',
    ageGroup: '10-18岁',
    price: 150
  }
])

// 返回按钮
const goBack = () => {
  uni.navigateBack()
}

// 点击课程跳转详情页
const selectCourse = (course) => {
  console.log('选择课程:', course)
  // 跳转到详情页并传参
  uni.navigateTo({
    url: `/pages/study-detail/study-detail?id=${course.id}&title=${encodeURIComponent(course.title)}`
  })
}
</script>


<style scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: linear-gradient(180deg, #e8f5e8 0%, #c8e6c9 50%, #81c784 100%);
  color: #2e7d32;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.status-bar {
  height: 44px;
  width: 100%;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn, .help-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.title {
  display: block;
  font-size: 18px;
  font-weight: bold;
  color: #1b5e20;
}

.subtitle {
  display: block;
  font-size: 11px;
  color: #4caf50;
  margin-top: 2px;
  letter-spacing: 1px;
}

.main-content {
  flex: 1;
  width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
}

.course-list {
  padding: 20px 0;
}

.course-item {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.course-image {
  width: 120px;
  height: 90px;
  background: #f1f8e9;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.image-placeholder {
  font-size: 12px;
  color: #81c784;
  text-align: center;
}

.course-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.course-title {
  font-size: 16px;
  font-weight: bold;
  color: #1b5e20;
  margin-bottom: 8px;
}

.course-desc {
  font-size: 14px;
  color: #4caf50;
  line-height: 1.4;
  margin-bottom: 12px;
}

.course-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.course-duration {
  font-size: 12px;
  color: #81c784;
}

.free-tag {
  background: #4caf50;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}
</style>
